package sword.offer.common;

/**
 * 生成列表
 * @author 胡宇轩
 * @Email: yuxuan.hu01@bianlifeng.com
 */
public class GenerateList {
    /**
     * 根据数组的values生成链表
     * */
    public static ListNode generate(int[] values){
        if(values.length == 0){
            return null;
        }
        ListNode head = new ListNode(values[0]);
        ListNode result = head;
        for (int i = 1; i < values.length; i++) {
            head.next = new ListNode(values[i]);
            head = head.next;
        }
        return result;
    }
}
